module.exports = Behavior({
  behaviors: [],
  properties: {

  },
  data: {
    actbill: null,
    pageload: false,
    pagelist: []

  },
  attached: function () { },
  ready: function () {

  },
  methods: {
    getpagelist(rest, strwhere, xcsorts, isupdate) {

      var actbill = this.data.actbill;
      if (!actbill) {
        return new Promise(function (resolve) {
          resolve({ status: -1 })
        })

      }
      if (this.pageload) {
        if (rest != 1) {
          return new Promise(function (resolve) {
            resolve({ status: -2 })
          })

        }
      }
      this.pageload = true;
      var that = this;
      return new Promise(function (resolve) {

        actbill.offset(that, rest, strwhere, xcsorts).then(function (result) {
          var updatemodel = {};
          if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {
            if (rest == 1) {
              updatemodel["pagelist"] = result["obj"]["modellist"];
            } else {
              if (result["obj"]["pagelist"].length > 0) {
                updatemodel["pagelist"] = that.data.pagelist.concat(result["obj"]["modellist"]);
              }
            }
          }
          updatemodel["pageload"] = false
          if (isupdate !== false) {

            that.setData(updatemodel);
          }
          else {

          }
          resolve({ status: 1, obj: updatemodel })
        })

      })
    },

  }
})